Programmatically synchronize a product across the Network
WPGlobalCart is a powerful WooCommerce plugin designed to streamline e-commerce operations within a WordPress MultiSite network. It offers a range of tools and features that simplify product management, making it an essential tool for businesses with multiple online stores.
Product Synchronization Made Easy
One of the standout features of the WPGlobalCart plugin is its user-friendly and efficient approach to product synchronization. Managing a diverse range of products across multiple websites within a WordPress MultiSite network can be a complex and time-consuming task. However, WPGlobalCart streamlines this process, offering a set of tools and features that make product synchronization a breeze.
Visual Interface for Intuitive Product Management
WPGlobalCart’s visual interface is the heart of its product synchronization capabilities. With a few clicks, you can initiate product synchronization between different websites in your network:
- Duplicate Products with Ease
- Update Products Universally
- Effortless Product Deletion
Programmatically synchronize a list of products across the Network
For developers and advanced users, the WPGlobalCart plugin offers a robust API (Application Programming Interface) that opens up a world of possibilities for custom product synchronization and integration with external systems. This API allows you to programmatically control and extend the plugin’s functionalities to suit your unique requirements.
Leveraging the WPGlobalCart Product Synchronisation API
The WPGlobalCart API exposes various methods and endpoints that can be used to interact with product data, categories, and other e-commerce elements within your WordPress MultiSite network. Let’s walk through a hypothetical scenario where you might want to programmatically synchronize product prices across your network.
include ( 'wp-load.php' ); $product_IDs = array ( 22, 24 ); $sync_data = array ( '_woogc_ps_sync_to' => array ( '3' => 'yes', '5' => 'yes' ), '_woogc_ps_maintain_child' => array ( '3' => 'yes', '5' => 'yes' ), '_woogc_ps_maintain_categories' => array ( '3' => 'no', '5' => 'yes' ), '_woogc_ps_maintain_stock' => array ( '3' => 'no', '5' => 'yes' ), 'return_interface_response' => TRUE ); global $WooGC; if ( ! isset ( $WooGC->ps_interfaces ) || ! is_object ( $WooGC->ps_interfaces ) ) { include_once(WOOGC_PATH . '/include/product-sync/class.woogc.ps.php'); include_once(WOOGC_PATH . '/include/product-sync/class.woogc.ps.main-product.php'); include_once(WOOGC_PATH . '/include/product-sync/class.woogc.ps.child-product.php'); include_once(WOOGC_PATH . '/include/product-sync/class.woogc.ps.interfaces.php'); $WooGC->ps_interfaces = new WooGC_PS_interfaces(); } if ( ! is_object ( $WooGC->ps_interfaces ) ) return; foreach ( $product_IDs as $product_ID ) { $response = $WooGC->ps_interfaces->product_save_main ( $product_ID, $sync_data ); print_r ( $response ); }
In this simplified example, we’ve created a sample code that utilizes the WPGlobalCart API to update a list of products across the network. The arguments list, takes some options along the required shop IDs. For example this block instruct the API to synchronize the provided product id to the Shops IDs 3 and 5.
'_woogc_ps_sync_to' => array ( '3' => 'yes', '5' => 'yes' )
You can customize this code to implement your specific synchronization logic and integrate with external systems or data sources.
By leveraging the WPGlobalCart API, you can automate complex synchronization processes, integrate with third-party services, and extend the plugin’s capabilities to meet your business needs.